﻿package org.xhs.report.common.utils
{

    public class Logger extends Object
    {
        private static var _enabled:Boolean = true;
        private static var _errorEnabled:Boolean = true;
        private static var _debugEnabled:Boolean = true;
        public static const TYPE_ERROR:String = "Error";
        public static const TYPE_DEBUG:String = "Debug";

        public function Logger()
        {
            return;
        }// end function

        static function obj2Str(param1, param2:String = "Debug") : String
        {
            var _loc_3:String = "";
            switch(typeof(param1))
            {
                case "object":
                {
                    _loc_3 = param1.toString();
                    break;
                }
                case "function":
                {
                    _loc_3 = "[function]";
                    break;
                }
                default:
                {
                    _loc_3 = param1.toString();
                    break;
                }
            }
            switch(param2)
            {
                case TYPE_ERROR:
                {
                    if (!_errorEnabled)
                    {
                        return "";
                    }
                    _loc_3 = "->ERROR: " + _loc_3;
                    break;
                }
                case TYPE_DEBUG:
                {
                    if (!_debugEnabled)
                    {
                        return "";
                    }
                    _loc_3 = "->DEBUG: " + _loc_3;
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return _loc_3;
        }// end function

        static function traceObj(param1:String) : void
        {
            if (param1)
            {
                trace(param1);
            }
            return;
        }// end function

        public static function get enabled() : Boolean
        {
            return _enabled;
        }// end function

        public static function set enabled(param1:Boolean) : void
        {
            _enabled = param1;
            return;
        }// end function

        public static function get errorEnabled() : Boolean
        {
            return _errorEnabled;
        }// end function

        public static function set errorEnabled(param1:Boolean) : void
        {
            _errorEnabled = param1;
            return;
        }// end function

        public static function get debugEnabled() : Boolean
        {
            return _debugEnabled;
        }// end function

        public static function set debugEnabled(param1:Boolean) : void
        {
            _debugEnabled = param1;
            return;
        }// end function

        public static function error(param1) : void
        {
            log(param1, TYPE_ERROR);
            return;
        }// end function

        public static function debug(param1) : void
        {
            log(param1, TYPE_DEBUG);
            return;
        }// end function

        public static function log(param1, param2:String = "Debug") : void
        {
            if (!_enabled)
            {
                return;
            }
            traceObj(obj2Str(param1, param2));
            return;
        }// end function

    }
}
